package net.hn.hnms.biz.meeting.service.impl;

import net.hn.hnms.biz.meeting.domain.MeetingPerson;
import net.hn.hnms.biz.meeting.mapper.MeetingPersonMapper;
import net.hn.hnms.biz.meeting.request.MeetingPersonReq;
import net.hn.hnms.biz.meeting.service.MeetingPersonService;
import net.hn.hnms.biz.meeting.vo.MeetingPersonVo;
import net.hn.hnms.sys.common.core.constant.Constants;
import net.hn.hnms.sys.common.core.exception.HuaNengException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MeetingPersonServiceImpl extends BaseService<MeetingPerson, MeetingPersonVo> implements MeetingPersonService {


    @Autowired
    private MeetingPersonMapper meetingPersonMapper;




    @Override
    public List<MeetingPersonVo> selectListSq(MeetingPersonReq meetingPerson) {
        List<MeetingPersonVo> list = meetingPersonMapper.selectListSq(meetingPerson );
        return list;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateBatchMeetingPerson(List<MeetingPersonReq> list) {
//        LambdaQueryWrapper<MeetingPerson> query = Wrappers.lambdaQuery();

        for (MeetingPersonReq meetingPersonReq:list){
//            query.eq(MeetingPerson::getPersonId, meetingPersonReq.getPersonId()).eq(MeetingPerson::getMeetingId,meetingPersonReq.getMeetingId());
            MeetingPerson meetingPerson = meetingPersonMapper.selectOne(meetingPersonReq);
            if(meetingPerson==null){
                throw new HuaNengException(Constants.FAIL, "确认添加参会人");
            }else {
                meetingPerson.setState(meetingPersonReq.getState());
                meetingPersonMapper.updateById(meetingPerson);
            }
        }
    }






}
